<?php

class Option_model extends Model {
	
	private $table 	= 'options';
	
	function Option_model() {
		parent::Model ();
	}
	
	function select_option() {
		$data = array ();
		
		$query = $this->db->query("SELECT `name`, `slogan`, `description`, `keywords`, `robots`, `googlebot`, `abstract`, `copyright`, `copyright2` FROM $this->table WHERE `id_lang` = '".get_admin_lang()."' LIMIT 1 ");
		
		if ( $query->num_rows () > 0 ) 
			$data = $query->row_array();
		
		$query->free_result ();
		
		//$this->db->cache_delete_all();
		
		return $data;
	}
	
	function update_option() {		
			
		$data = array(			
			'name'			=> isset( $_POST['name'] ) ? htmlspecialchars( $_POST['name'] ) : '',
			'slogan'		=> isset( $_POST['slogan'] ) ? htmlspecialchars( $_POST['slogan'] ) : '',
			'description'	=> isset( $_POST['description'] ) ? htmlspecialchars( $_POST['description'] ) : '',
			'keywords'		=> isset( $_POST['keywords'] ) ? htmlspecialchars( $_POST['keywords'] ) : '',
			'robots'		=> isset( $_POST['robots'] ) ? htmlspecialchars( $_POST['robots'] ) : '',
			'googlebot'		=> isset( $_POST['googlebot'] ) ? htmlspecialchars( $_POST['googlebot'] ) : '',
			'abstract'		=> isset( $_POST['abstract'] ) ? htmlspecialchars( $_POST['abstract'] ) : '',
			'copyright'		=> isset( $_POST['copyright'] ) ? $_POST['copyright'] : '',
			'copyright2'	=> isset( $_POST['copyright2'] ) ? $_POST['copyright2'] : '',
		);
				
		$this->db->where('id_lang', get_admin_lang() );	
		$this->db->update( $this->table, $data);	
	}
	
}
?>